package com.zhuang.Iterator;

/**
 * @Classname Client
 * @Description 迭代器模式 测试类
 * @Date 2021/3/28 12:54
 * @Created by dell
 */

public class Client {
    public static void main(String[] args) {
        StudentAggregateImpl aggregate = new StudentAggregateImpl();
        //添加元素
        aggregate.addStudent(new Student("张三", "001"));
        aggregate.addStudent(new Student("李四", "002"));
        aggregate.addStudent(new Student("王五", "003"));
        aggregate.addStudent(new Student("赵六", "004"));
        aggregate.addStudent(new Student("田七", "005"));

        //遍历聚合对象
        StudentIterator iterator = aggregate.getStudentIterator();
        //遍历
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student);
        }

    }
}
